#include<bits/stdc++.h>
#define y1 Y1
#define fi first
#define endl "\n"
#define se second
#define PI acos(-1)
#define int long long
#define pb(x) push_back(x)
#define PII pair<int, int>
#define Yes cout << "Yes\n";
#define No cout << "No\n";
#define YES cout << "YES\n";
#define NO cout << "NO\n";
#define _for(i, a, b) for(int i = a; i <= b; ++i)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;

const int N = 1e5 + 10;
const int mod = 1e9 + 7;

int jiecheng[N], niyuan[N];

int ksm(int a, int b, int mod) {
	int ret = 1;
	while(b) {
		if(b & 1)ret = ret * a % mod;
		b >>= 1;
		a = a * a % mod;
	}
	return ret;
}

signed main() {
	IOS;
	jiecheng[0] = 1;
	niyuan[0] = 1;
	int t;
	cin >> t;
	for(int i = 1; i <= 1000; ++i) {
		jiecheng[i] = jiecheng[i - 1] * i % mod;
		niyuan[i] = niyuan[i - 1] * ksm(i, mod - 2, mod) % mod; 
	}
	while(t-- ){
		int a, b;
		cin >> a >> b;
		cout << jiecheng[a] * niyuan[b] % mod * niyuan[a - b] % mod << endl;
	} 
	return 0;
}

